package br.ucb.musicbay.musica;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

public class MusicaDataModel extends ListDataModel<Musica> implements SelectableDataModel<Musica>{

	public MusicaDataModel(List<Musica> list){
		super(list);
	}
	
	@Override
	public Musica getRowData(String rowkey) {
		@SuppressWarnings("unchecked")
		List<Musica> lista = (List<Musica>) getWrappedData();
		for (Musica musica : lista) {
			if(musica.getIdMusica().equals(Integer.parseInt(rowkey)))
				return musica;
		}
		return null;
	}

	@Override
	public Object getRowKey(Musica musica) {
		return musica.getIdMusica();
	}

}
